/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ServiceOfRestful;
import java.io.IOException;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.net.httpserver.HttpServer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author truongtud
 */
public class ShoppingCartStartup {
     public  static HashMap<Integer,HashMap<String,Integer>> clients=new HashMap<Integer,HashMap<String ,Integer>>();
     public static  ArrayList<Product> products=new ArrayList();
     static String URI="http://localhost:9990/ebay";
     
    public static void initProducts(){
         Product pr1=new Product("tao",12,3);
            Product pr2=new Product("xoai",7,6);
            Product pr3=new Product("oi",3,5);
            Product pr4=new Product("man",23,3);
            Product pr5=new Product("cam",7,90);
            Product pr6=new Product("na",35,5);
            products.add(pr1);
            products.add(pr2);
            products.add(pr3); 
            products.add(pr4);
            products.add(pr5);
            products.add(pr6);
    }
    public static void main(String[]args){
       ShoppingCartStartup.initProducts();
        HttpServer server;
        try {
            ShoppingCartRestful rest =new ShoppingCartRestful();      
            server = HttpServerFactory.create(URI);
            server.start();
          //  System.out.println(rest.getAllProducts());
            System.out.println("Press Enter to stop the server. ");
            System.in.read();
            server.stop(0);
        } catch (IOException ex) {
            Logger.getLogger(ShoppingCartStartup.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(ShoppingCartStartup.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        
    }
   
    
}
